#ifndef COMMAND_AUDIO_COMMAND_IN_H_
#define COMMAND_AUDIO_COMMAND_IN_H_

//this commad file declare the
//UDP Audio command 

#include "ctType.h"
#pragma pack(1)

namespace AudioCmdIn
{
        //Cmd define
        enum {
                //can not over 255
                CMDIN_RELAY_NULL                = 0x10,
                CMDIN_JOIN_RELAY_ENGINE         = 0x11,
                CMDIN_RELAY_AUDIO_DATA          = 0x12,
                CMDIN_REQ_RESEND_PACKET         = 0x13,
                //can not over 255
        };

        //UDP Package Head
        struct stVOIPRelayHead
        {
                stVOIPRelayHead()
                {
                        pkg_len_ = 0;
                        cmd_ = CMDIN_RELAY_NULL;
                }
                stVOIPRelayHead(BYTE cmd):
                        cmd_(cmd)
                {
                        pkg_len_ = 0;
                }
                DWORD pkg_len_;
                BYTE cmd_;
        };

        //user request add to relay engine
        struct stJoinRelayEngine :
                stVOIPRelayHead
        {
                stJoinRelayEngine():
                        stVOIPRelayHead(CMDIN_JOIN_RELAY_ENGINE)
                {
                        client_id_ = 0;
                }
                WORD client_id_; 
        };

        //client request realy audio/vedio data
        struct stRelayAudioData:
                stVOIPRelayHead
        {
                stRelayAudioData():
                        stVOIPRelayHead(CMDIN_RELAY_AUDIO_DATA)
                {
                        client_id_ = 0;
                        data_size_ = 0;
                }
                WORD client_id_;
                DWORD data_size_;
                BYTE data[0];
                DWORD getSize() const
                {
                        return sizeof(*this)+data_size_*sizeof(data[0]);
                }
        };

        //request resend packet.
        struct stReqResendPacket :
                stVOIPRelayHead
        {
                stReqResendPacket():
                        stVOIPRelayHead(CMDIN_REQ_RESEND_PACKET)
                {
                        stream_from_ = 0;
                        data_type_ = 0;
                        seq_begin_ = 0;
                        seq_end_ = 0;
                }
                DWORD stream_from_;
                BYTE data_type_;
                DWORD seq_begin_;
                DWORD seq_end_;
        };
};

#define VOIP_RELAY_HEAD_LEN sizeof(AudioCmdIn::stVOIPRelayHead)


#pragma pack()

#endif //COMMAND_AUDIO_COMMAND_IN_H_
